#include <stdio.h>
#include <stdlib.h>

typedef struct ListNode {
    int val;
    struct ListNode *next;
} ListNode;

ListNode *createList(int N) {
    ListNode *head = NULL;
    ListNode *tail = NULL;
    for (int i = 0; i < N; i++) {
        int num;
        scanf("%d", &num);
        ListNode *newNode = (ListNode *)malloc(sizeof(ListNode));
        newNode->val = num;
        newNode->next = NULL;
        if (head == NULL) {
            head = newNode;
            tail = newNode;
        } else {
            tail->next = newNode;
            tail = newNode;
        }
    }
    return head;
}

void findMaxMin(ListNode *head) {
    if (head == NULL) {
        return;
    }
    int max = head->val;
    int min = head->val;
    int pos1 = 1;
    int pos2 = 1;
    ListNode *p = head;
    int count = 1;
    while (p!= NULL) {
        if (p->val > max) {
            max = p->val;
            pos1 = count;
        }
        if (p->val < min) {
            min = p->val;
            pos2 = count;
        }
        p = p->next;
        count++;
    }
    printf("max=%d,pos1=%d\n", max, pos1);
    printf("min=%d,pos2=%d\n", min, pos2);
}

int main() {
    int N;
    scanf("%d", &N);
    ListNode *head = createList(N);
    findMaxMin(head);
    return 0;
}

